package com.usian.controller;

import com.usian.pojo.staff.Staff;
import com.usian.service.StaffService;
import com.usian.vo.StaffVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.List;
@Controller
@RequestMapping("/staff")
public class StaffController {

    @Autowired
    private StaffService staffService;


    @RequestMapping("/findAll")
    public String findAll(Model model){
        List<StaffVo> list = staffService.findAll();
        model.addAttribute("list",list);
        return "list";
    }

    @RequestMapping("/toUser")
    public String toUser(){
        return "add";
    }

    @PostMapping("/add1")
    public String add(Staff staff){
        staffService.add(staff);
        return "redirect:/staff/findAll";
    }

    @RequestMapping("/del")
    public String del(Integer id){
        staffService.del(id);
        return "redirect:/staff/findAll";
    }



}
